var cc__decorate = __decorate;
var cc__awaiter = __awaiter;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2NodeManager = require("NodeManager");
var $2Pool = require("Pool");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var ccp_menu = cc__decorator.menu;
var d = "resources/Prefab/items/TiliItem";
var def_GlobalTili = /* */function (_cc$Component15) {
  function _ctor() {
    var _this39;
    babel_classCallCheck(this, _ctor);
    _this39 = _callSuper(this, _ctor, arguments);
    _this39.numCoins = 10;
    _this39.random1 = -90;
    _this39.random2 = 90;
    _this39.createTime = .15;
    _this39.standingTime = .2;
    _this39.moveTime = .5;
    return _this39;
  }
  babel_inherits(_ctor, _cc$Component15);
  return babel_createClass(_ctor, [{
    key: "goldCoinFlying",
    value: function goldCoinFlying(e, t) {
      var _this40 = this;
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
      var o = 0;
      this.unscheduleAllCallbacks();
      return new Promise(function (r) {
        return cc__awaiter(_this40, undefined, undefined, /* */babel_regeneratorRuntime().mark(function _callee() {
          var _this41 = this;
          var i;
          var l;
          var _loop;
          var _n11;
          return babel_regeneratorRuntime().wrap(function _callee$(_context2) {
            while (1) {
              switch (_context2.prev = _context2.next) {
                case 0:
                  i = null;
                  l = $2NodeManager.default.Instance.getCanvasNode();
                  i = n || l;
                  _loop = /* */babel_regeneratorRuntime().mark(function _loop() {
                    var n;
                    var s;
                    var l;
                    return babel_regeneratorRuntime().wrap(function _loop$(_context) {
                      while (1) {
                        switch (_context.prev = _context.next) {
                          case 0:
                            _context.next = 2;
                            return $2Pool.default.get(d);
                          case 2:
                            n = _context.sent;
                            n.parent = i;
                            n.zIndex = 15;
                            n.scale = 1.2;
                            n.setPosition(i.convertToNodeSpaceAR(e));
                            s = Math.floor(Math.random() * (_this41.random2 - _this41.random1 + 1) + _this41.random1);
                            l = Math.floor(Math.random() * (_this41.random2 - _this41.random1 + 1) / 1.5 + _this41.random1 / 1.5);
                            cc.tween(n).by(_this41.createTime, {
                              x: s,
                              y: l
                            }, {
                              easing: "bounceOut"
                            }).start();
                            _this41.scheduleOnce(function () {
                              cc.tween(n).to(_this41.moveTime, {
                                position: i.convertToNodeSpaceAR(t),
                                scale: .7
                              }, {
                                easing: "sineIn"
                              }).call(function () {
                                if (++o >= _this41.numCoins) {
                                  o = 0;
                                  r();
                                }
                                $2Pool.default.put(d, n);
                              }).start();
                            }, _this41.standingTime + _this41.createTime);
                          case 6:
                          case "end":
                            return _context.stop();
                        }
                      }
                    }, _loop);
                  });
                  _n11 = 0;
                case 4:
                  if (!(_n11 < this.numCoins)) {
                    _context2.next = 9;
                    break;
                  }
                  return _context2.delegateYield(_loop(), "t0", 6);
                case 6:
                  _n11++;
                  _context2.next = 4;
                  break;
                case 9:
                case "end":
                  return _context2.stop();
              }
            }
          }, _callee, this);
        }));
      });
    }
  }]);
}(cc.Component);
def_GlobalTili = cc__decorate([ccp_ccclass, ccp_menu("v-lez/GlobalTili")], def_GlobalTili);
exports.default = def_GlobalTili;